function [y,epsi,phi]=genrootarp(lmb,sigma,nd,nt,cot,pct);
% function [y,epsi,phi]=genrootarp(lmb,sigma,nd,nt,cot,pct);
% Compute the coefficients of an AR(p) given the roots in 
% lmb and simulate the data using createarp.m 
%
% ar    (1xnlag) autoregressive coefficients
% sigma standard deviation 
% nd    number of obs to discard 
% nt    number of obs to retain 
% cot   if 0 or not specified constant not included 
%       if = 1 constant only 
%       if = 2 constant and trend 
% pct mean or mean and constant coefficient 
%
%
% Roots should be greater than one 
% for stationarity as in rootpol 
% eg. lmb =[5 2.5] corresponds to 
% stationary AR with 
% phi(1)=0.6 and phi(2)=-0.08
% as in Hamilton 
%
% epsi are the errors 
% phi  the AR coefficients for 
% y(t)=phi(1)*y(t-1) + ....+phi(p)*y(t-p) + eps(t)
% AJ 1/28/04
if nargin < 6; 
    cot = 0; 
    pct = 0; 
end 

lmb=1./lmb; 
phi=poly(lmb); 
phi=-phi(2:end); 
[y,epsi]=createarp(phi,sigma,nd,nt,cot,pct);